package com.taxicalculator.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;


import com.taxicalculator.ui.R;
/*
 * This Activity allows the user to rate the app
 */
public class RatingActivity extends Activity {

	  private RatingBar ratingBar;
	  private TextView ratingValue;
	  

	  @Override
	  public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ratingmain);

		addListenerOnRatingBar();
		

	  }
//create a listener for the star rating bar
	  public void addListenerOnRatingBar() {

		ratingBar = (RatingBar) findViewById(R.id.ratingBar1);
		ratingValue = (TextView) findViewById(R.id.txtRatingValue);

		ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
//if the user selects a different number of stars, update the value
			public void onRatingChanged(RatingBar ratingBar, float rating,	boolean fromUser) {

				ratingValue.setText(String.valueOf(rating));

			}
		});
	  }
	  
//when the button is clicked, display a message
	  public void onSubmitClick(View v) {

		
		String message= "Thank You for Rating us!";

				Toast.makeText(RatingActivity.this, message, Toast.LENGTH_LONG).show();
				Intent mainActivityIntent= new Intent(this, MainActivity.class);
				startActivity(mainActivityIntent);
	

	  }}
